/* ---------------------------------------------------------------------------
 * This software is in the public domain, furnished "as is", without technical
 * support, and with no warranty, express or implied, as to its usefulness for
 * any purpose.
 *
 * Scanner.h
 *
 * Author: Guillaume Boissé
 * -------------------------------------------------------------------------*/

#ifndef _JSP_SCANNER_H
#define _JSP_SCANNER_H

#include "Token.h"
#include "Types.h"

namespace jsp
{

class Scanner
{
public:
    struct Location
    {
        Location(s32 b, s32 e) : begin(b), end(e) {}
        Location() : begin(0), end(0) {}

        bool isValid() const {return (begin >= 0 && end >= begin);}
        static Location invalid() {return Location(-1, -1);}

        s32 begin;
        s32 end;
    };

    void init(const s8* pSource);
    void term();

    Token::Value next();
    Token::Value current();

    Location location() const;

protected:
    Location m_location;
};

} // namespace jsp

#endif // _JSP_SCANNER_H
